#include<iostream>
#include<cstdlib>
#include<algorithm>
#include<string>
#include<cstring>
using namespace std;
typedef struct S
{
	char name[25];
	int ac;
	int a[20];
	int sum;
}S;
S s[1010];
int b[20];
int n, m, g;
bool cmp(S a,S b)
{
	if (a.sum > b.sum) {
		return 1;
	}
	else  {
		if (a.sum == b.sum) {
			if (strcmp(a.name, b.name) > 0) {
				return 0;
			}
			else {
				return 1;
			}
		}
		else {
			return 0;
		}
	}
}
int main()
{
	while (cin >> n >> m >> g) {
		if (n == 0) {
			break;
		}
		for (int i = 0; i < m; i++) {
			cin >> b[i];
		}
		memset(s, 0, sizeof(s));
		int count = 0;
		for (int i = 0; i < n; i++) {
			cin >> s[i].name;
			cin >> s[i].ac;
			for (int j = 0; j < s[i].ac; j++) {
				cin >> s[i].a[j];
				s[i].sum += b[s[i].a[j] - 1];
			}
			if (s[i].sum >= g) {
				count++;
			}
		}
		cout << count << endl;
		sort(s, s + n, cmp);
		for (int i = 0; i < count; i++) {
			cout << s[i].name <<" "<< s[i].sum << endl;
		}
	}
	return 0;
}